Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
bem-classnames
Advanced tools
bem-classnames is a simple utility to manage BEM class names on React.
Inspired by classnames.
npm install bem-classnames
var cx = require('bem-classnames');
cx(/* classes, [...props|className] */);
Simple
var classes = {
name: 'button',
modifiers: ['color', 'block'],
states: ['disabled']
};
cx(classes, { color: 'green', block: true }); // "button button--green button--block"
cx(classes, { disabled: true }); // "button is-disabled"
cx(classes, 'a b', ['c', 'd']); // "button a b c d"
Custom prefix
// Default prefixes:
//
// cx.prefixes = {
// modifiers: '{name}--',
// states: 'is-'
// };
cx.prefixes.modifiers = '-';
cx(classes, { color: 'green' }); // "button -green"
// You can add the prefixes
cx.prefixes.foo = 'foo-';
classes.foo = ['a', 'b'];
cx(classes, { a: true, b: true }); // "button foo-a foo-b"
with React and ES6
import React from 'react';
import cx from 'bem-classnames';
class Button extends React.Component {
render() {
let classes = {
name: 'button',
modifiers: ['color', 'size'],
states: ['disabled']
};
return (
<button className={cx(classes, this.props, this.props.className)}>
{this.props.children}
</button>
);
}
}
React.render(
<Button color="green" size="xl" disabled={true} className="a b">Alo!</Button>,
document.getElementById('example')
);
// "button button--green button--xl a b is-disabled"
for manage the elements of BEM
class Button extends React.Component {
render() {
let classes = {
button: {
name: 'button',
modifiers: ['color', 'size'],
states: ['disabled']
},
button__inner: {
name: 'button__inner',
modifiers: ['align']
}
};
return (
<button className={cx(classes.button, this.props, this.props.className)}>
<span className={cx(classes.button__inner, this.props)}>
{this.props.children}
</span>
</button>
);
}
}
React.render(
<Button color="green" align="center">Alo!</Button>,
document.getElementById('example')
);
// button -> "button button--green"
// span -> "button__inner button__inner--center"
FAQs
A simple utility to manage BEM class names on React
The npm package bem-classnames receives a total of 0 weekly downloads. As such, bem-classnames popularity was classified as not popular.
We found that bem-classnames demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.